<?php

namespace common\models\system;

use Yii;

/**
 * This is the model class for table "system_config".
 *
 * @property int $id
 * @property string $name 配置key
 * @property string|null $value 配置value
 * @property string $desc 配置描述
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class SystemConfig extends \common\models\base\BaseModel
{
    const NAME_C_HOME_PAGE_BANNER_TYPE_IMG = 1;
    const NAME_C_HOME_PAGE_BANNER_TYPE_VIDEO = 2;

    const NAME_C_HOME_PAGE_TITLE = 'c_home_page_title';
    const NAME_C_HOME_PAGE_BANNER_TYPE = 'c_home_page_banner_type';
    const NAME_C_HOME_PAGE_BANNER_IMAGE = 'c_home_page_banner_image';
    const NAME_C_HOME_PAGE_BANNER_VIDEO = 'c_home_page_banner_video';
    const NAME_C_HOME_PAGE_BANNER_CONTENT = 'c_home_page_banner_content';

    public static $names = [
        self::NAME_C_HOME_PAGE_TITLE => '首页标题',
        self::NAME_C_HOME_PAGE_BANNER_TYPE => '首页类型',
        self::NAME_C_HOME_PAGE_BANNER_IMAGE => '首页图片',
        self::NAME_C_HOME_PAGE_BANNER_VIDEO => '首页视频',
        self::NAME_C_HOME_PAGE_BANNER_CONTENT => '首页内容',
    ];

    // 微信小程序keys
    public static $wxMiniKeys = [
        self::NAME_C_HOME_PAGE_TITLE,
        self::NAME_C_HOME_PAGE_BANNER_TYPE,
        self::NAME_C_HOME_PAGE_BANNER_IMAGE,
        self::NAME_C_HOME_PAGE_BANNER_VIDEO,
        self::NAME_C_HOME_PAGE_BANNER_CONTENT,
    ];

    // 微信小程序类型
    public static $cHomePageTypes = [
        self::NAME_C_HOME_PAGE_BANNER_TYPE_IMG => '图片',
        self::NAME_C_HOME_PAGE_BANNER_TYPE_VIDEO => '视频',
    ];

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'system_config';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['value'], 'string'],
            [['created_at', 'updated_at'], 'integer'],
            [['name', 'desc'], 'string', 'max' => 64],
            [['name'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '配置key',
            'value' => '配置value',
            'desc' => '配置描述',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }
}
